import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import no.nordicsemi.android.uart.data.UARTServiceData
import no.nordicsemi.android.uart.view.InputSection
import no.nordicsemi.android.uart.view.OutputSection
import no.nordicsemi.android.uart.view.UARTViewEvent
import no.nordicsemi.android.uart.view.CurveSection
import no.nordicsemi.android.ui.view.ScreenSection

@Composable
internal fun UARTChartView(
    state: UARTServiceData,
    onEvent: (UARTViewEvent) -> Unit
) {
    Column(
        horizontalAlignment = Alignment.CenterHorizontally,
        modifier = Modifier
            .padding(16.dp)
            .fillMaxSize()
    ) {

        Box(modifier = Modifier.weight(1f)) {
            ScreenSection {
                Column(modifier = Modifier.fillMaxWidth()) {
                    CurveSection(state.displayMessages, onEvent)
                }
            }
        }
    }
    Spacer(modifier = Modifier.size(16.dp))

    InputSection(onEvent = onEvent)
}